package com.example.redistemplate;

import com.example.pojo.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

@SpringBootTest
class RedisTemplateApplicationTest1 {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @Test
    void testString() {
        ValueOperations value = redisTemplate.opsForValue();
        value.set("name","露西");
        Object o = value.get("name");
        System.out.println(o);
    }

    @Test
    void testUser() {
        User user = new User("李四", 42);
        ValueOperations value = redisTemplate.opsForValue();
        value.set("user",user);
        Object o = value.get("user");
        System.out.println(o);
    }

}
